package com.chenhao.springcloud.chenhaomqservice.controller;

import com.chenhao.springcloud.chenhaomqservice.service.MQSender;

/**
 *
 * 测试
 *
 * @author chenhao
 *
 * @date 2020/5/26 16:11
 */
import com.chenhao.springcloud.chenhaomqservice.service.Testservice;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.servlet.mvc.AbstractController;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.time.LocalDateTime;

@RestController
@RequestMapping("/mq")
public class MqController{

    @Autowired
    private MQSender mqSender;
    @Autowired
    private Testservice testservice;

    //http://localhost:8080/api/mq/send/delay?delayTime=6000
    //http://localhost:8080/api/mq/send/delay?delayTime=10000

    @GetMapping(value = "/send/delay")
    public void sendDelay(int delayTime) {
        String msg = "hello delay";
        System.out.println("发送开始时间:" + LocalDateTime.now() + "测试发送delay消息====>" + msg);
        mqSender.sendDelay(msg, delayTime);
    }


    @GetMapping("/")
    public void index(HttpServletRequest request, HttpServletResponse response) throws IOException {
        response.sendRedirect("https://www.baidu.com/");
    }

    @GetMapping("/test")
    public void test() throws InterruptedException {
        testservice.testAop();
    }
}
